package com.yf.controller;

import com.yf.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {
    @RequestMapping("save")
    public User save(User user){
        User user1 = new User("yf","123",11);
//        int i = 1/0; 模拟全局异常处理
        return user1;
    }
    @RequestMapping("list")
    public  String list(Model model){
        List<User> users =  new ArrayList<User>();
        User user1 = new User("yf1","123",11);
        User user2 = new User("yf2","123",25);
        User user3 = new User("yf3","123",60);
        users.add(user1);
        users.add(user2);
        users.add(user3);
        model.addAttribute("stuList",users);
        return "list";
    }
}
